package cn.wanda.bi.sunshine.platform.server.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.wanda.bi.sunshine.platform.server.aspect.AuthUser;

import cn.wanda.bi.sunshine.platform.server.controller.response.SysAppGroupResponse;
import cn.wanda.bi.sunshine.platform.server.controller.response.common.SimpleResponse;
import cn.wanda.bi.sunshine.platform.server.service.MenuPermissionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * Created by James on 17/7/11.
 */
@Api(description = "菜单权限")
@RestController
@RequestMapping(value = "/v1/dmp/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DMPMenuPermissionsController {

    public static final Logger logger = LoggerFactory.getLogger(DMPMenuPermissionsController.class);

    @Autowired
    private MenuPermissionsService menuPermissionsService;

    @AuthUser
    @ApiOperation("获取res列表, 传入参数：1，登录校验码 2，登录用户名 3，登录时间 4，角色id 输出数据：SysAppGroupResponse对象列表")
    @RequestMapping(value = "/resources", method = RequestMethod.GET)
    public SimpleResponse<List<SysAppGroupResponse>> getResourceList(@ApiParam(value = "角色id") @RequestParam(value = "roleId", defaultValue = "1") Integer roleId,
    		@ApiParam(value = "登录校验码") @RequestHeader(value = "token") String token
    		) {
        return menuPermissionsService.getResourceList(roleId);
    }

}
